package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.StrategyComment;
import cn.wolfcode.trip.base.query.StrategyCommentQueryObject;
import cn.wolfcode.trip.base.service.IStrategyCommentService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by 24106 on 2018/8/29.
 */
@RestController
@RequestMapping("strategycomments")
public class StrategyCommentController {

    @Autowired
    private IStrategyCommentService strategycommentService;

    /**
     * 查询出页面所有的攻略页面的信息
     */
    @RequestMapping(value = "/{userId}",method = RequestMethod.GET)
    public PageInfo query(StrategyCommentQueryObject qo){
        //设置状态为为发布状态
        qo.setState(StrategyComment.STATE_ISSUE);
        qo.setPageSize(0);
        System.out.println(qo.getUserId());
        //设置排序的方式
        qo.setOrderBy("sc.createTime desc");
        return strategycommentService.query(qo);
    }

    /**
     * 查询index.html页面的轮播人物信息
     * @param qo
     * @return
     */
    @RequestMapping(value = "query",method = RequestMethod.GET)
    public PageInfo queryForList(StrategyCommentQueryObject qo){
        //设置状态为为发布状态
        qo.setState(StrategyComment.STATE_ISSUE);
        //设置排序的方式
        qo.setOrderBy("sc.createTime desc");
        return strategycommentService.query(qo);
    }
}
